import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../components/Home.vue'
import homePage from '../components/Children/Homepage.vue'
import DisCove from '../components/Children/Discove.vue'
import Cat from '../components/Children/Cat.vue'
import MyInfo from '../components/Children/Myinfo.vue'
import Type from '../views/Type.vue'
import GuessLike from '../components/Children/GuessLike.vue'
import Goostype from '../components/Children/Goostype.vue'
import TypeList from '../components/Children/TypeList.vue'
import detals from '../components/Children/Details.vue'
import goods from '../components/Details/Goods.vue'
import Evaluation from '../components/Details/Evaluation.vue'
import Detailsp from '../components/Details/Detailsp.vue'
import Login from '../views/login.vue'
import EmailLogin from '../components/login/emailLogin.vue'
import Accountlogin from '../components/login/Accountlogin.vue'
import Register from '../views/Register.vue'








Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'home',
    component: Home,
    children: [{
        path: '/',
        redirect: '/homePage'
      },
      {
        path: '/homePage',
        name: 'homePage',
        component: resolve => require(['../components/Children/Homepage'], resolve)
      },
      // {path:'/discove',name:'discove',component:DisCove},
      {
        path: '/discove',
        name: 'discove',
        component: resolve => require(['../components/Children/Discove.vue'], resolve)
      },
      {
        path: '/Message',
        name: 'Message',
        meta: {
          requireAuth: true
        },
        component: resolve => require(['../views/Message.vue'], resolve)
      },
      {
        path: '/Type',
        name: 'Type',
        component: Type,
        children: [{
          path: '/typeRight',
          name: 'typeRight',
          component: resolve => require(['../components/Type/TypeRight.vue'], resolve)
        }]
      },

      {
        path: '/cat',
        component: Cat
      },
      {
        path: '/myinfo',
        name: 'myinfo',
        meta: {
          requireAuth: true
        },
        component: MyInfo
      },
      {
        path: '/guessLike',
        component: GuessLike
      },
      {
        path: '/goosType',
        name: 'goosType',
        component: Goostype
      },
      {
        path: '/typeList',
        name: 'typeList',
        component: TypeList
      },



    ]
  },
  {
    path: '/details/:gid',
    name: 'details',
    component: detals
  },
  {
    path: '/goods',
    name: 'goods',
    component: goods
  },
  {
    path: '/evaluation',
    name: 'evaluation',
    component: Evaluation
  },
  {
    path: '/detailsp',
    name: 'detailsp',
    component: Detailsp
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    children: [{
        path: '/emailLogin',
        name: 'emailLogin',
        component: EmailLogin
      },
      {
        path: '/accountlogin',
        name: 'accountlogin',
        component: Accountlogin
      },

    ]
  },
  {
    path: '/register/',
    name: 'register',
    component: Register
  },
  {
    path: '/checkout',
    name: 'checkout',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../views/checkout.vue'], resolve),
    children: [{
        path: '/address',
        name: 'address',
        component: resolve => require(['../components/checkout/Address.vue'], resolve)
      }

    ]
  },
  {
    path: '/newPay',
    name: 'newPay',
    component: resolve => require(['../views/newPay.vue'], resolve)
  },
  {
    path: '/addressList',
    name: 'addressList',
    component: resolve => require(['../views/addressList.vue'], resolve)
  },
  {
    path: '/addAddress',
    name: 'addAddress',
    component: resolve => require(['../views/addAddress.vue'], resolve)
  },
  {
    path: '/Myorder/:acid',
    name: 'Myorder',
    component: resolve => require(['../views/Myorder.vue'], resolve)
  },
  {
    path: '/Orderdetails',
    name: 'Orderdetails',
    component: resolve => require(['../views/Orderdetails.vue'], resolve)
  },
  {
    path: '/mjrpay/:msg',
    name: 'mjrpay',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../views/mjrpay.vue'], resolve)
  },
  {
    path: '/WriteEvaluation/:oid',
    name: 'WriteEvaluation',
    component: resolve => require(['../views/WriteEvaluation.vue'], resolve)
  },
  {
    path: '/EvaluationList/:gid',
    name: 'EvaluationList',
    component: resolve => require(['../components/Details/EvaluationList.vue'], resolve)
  },
  {
    path: '/chatroom',
    name: 'chatroom',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/Chat/chatroom.vue'], resolve)
  },
  {
    path: '/CustomerServiceChat',
    name: 'CustomerServiceChat',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/Chat/CustomerServiceChat.vue'], resolve)
  },
  {
    path: '/SpecialActivities',
    name: 'SpecialActivities',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/Chat/SpecialActivities.vue'], resolve)
  },
  {
    path: '/chat/:fid',
    name: 'chat',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/Chat/chat.vue'], resolve)
  },
  {
    path: '/videDetail/:vid',
    name: 'videDetail',
    component: resolve => require(['../components/disvcove/videDetail.vue'], resolve)
  },
  {
    path: '/ImgShare',
    name: 'ImgShare',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/disvcove/ImgShare.vue'], resolve)
  },
  {
    path: '/videoShare',
    name: 'videoShare',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/disvcove/videoShare.vue'], resolve)
  },
  {
    path: '/Attention',
    name: 'Attention',
    component: resolve => require(['../components/disvcove/Attention.vue'], resolve)
  },
  {
    path: '/Video',
    name: 'Video',
    component: resolve => require(['../components/disvcove/Video.vue'], resolve)
  },
  {
    path: '/videList',
    name: 'videList',
    component: resolve => require(['../components/disvcove/videList.vue'], resolve)
  },
  {
    path: '/SearchVideo',
    name: 'SearchVideo',
    component: resolve => require(['../components/disvcove/SearchVideo.vue'], resolve)
  },
  {
    path: '/SearchGoods',
    name: 'SearchGoods',
    component: resolve => require(['../views/SearchGoods.vue'], resolve)
  },
  {
    path: '/SearchResults/:Sname',
    name: 'SearchResults',
    component: resolve => require(['../components/disvcove/SearchResults.vue'], resolve)
  },
  {
    path: '/GoodsResults/:pname',
    name: 'GoodsResults',
    component: resolve => require(['../views/GoodsResults.vue'], resolve)
  },
  {
    path: '/chatNew',
    name: 'chatNew',
    meta: {
      requireAuth: true
    },
    component: resolve => require(['../components/Chat/chatNew.vue'], resolve)
  },
  {
    path: '/AddFriends',
    name: 'AddFriends',
    component: resolve => require(['../components/Chat/AddFriends.vue'], resolve)
  },
  {
    path: '/FriendsRequest',
    name: 'FriendsRequest',
    component: resolve => require(['../components/Chat/FriendsRequest.vue'], resolve)
  },
  {
    path: '/ContactList',
    name: 'ContactList',
    component: resolve => require(['../components/Chat/ContactList.vue'], resolve)
  },
  {
    path: '/Themes',
    name: 'Themes',
    component: resolve => require(['../components/Chat/Themes.vue'], resolve)
  },
  {
    path: '/Voice',
    name: 'Voice',
    component: resolve => require(['../components/Chat/Voice.vue'], resolve)
  },
  {
    path: '/AmountInput',
    name: 'AmountInput',
    component: resolve => require(['../components/Chat/AmountInput.vue'], resolve)
  },
  {
    path: '/DetailsRedenvelopes',
    name: 'DetailsRedenvelopes',
    component: resolve => require(['../components/Chat/DetailsRedenvelopes.vue'], resolve)
  },
  {
    path: '/SendRedenvelopes',
    name: 'SendRedenvelopes',
    component: resolve => require(['../components/Chat/SendRedenvelopes.vue'], resolve)
  },
  {
    path: '/PersonalSettings',
    name: 'PersonalSettings',
    component: resolve => require(['../components/MyInfo/PersonalSettings.vue'], resolve)
  },
  {
    path: '/BasicInfo',
    name: 'BasicInfo',
    component: resolve => require(['../components/MyInfo/BasicInfo.vue'], resolve)
  },
  {
    path: '/AddressManagement',
    name: 'AddressManagement',
    component: resolve => require(['../components/MyInfo/AddressManagement.vue'], resolve)
  },
  {
    path: '/ConsumerDetails',
    name: 'ConsumerDetails',
    component: resolve => require(['../components/Order/ConsumerDetails.vue'], resolve)
  },
  {
    path: '/BrowseHistory',
    name: 'BrowseHistory',
    component: resolve => require(['../components/Order/BrowseHistory.vue'], resolve)
  },
  {
    path: '/LogisticsInfo',
    name: 'LogisticsInfo',
    component: resolve => require(['../components/Order/LogisticsInfo.vue'], resolve)
  },
  {
    path: '/OrderDetailsNow',
    name: 'OrderDetailsNow',
    component: resolve => require(['../components/Order/OrderDetailsNow.vue'], resolve)
  },
  {
    path: '/PaymentSafe',
    name: 'PaymentSafe',
    component: resolve => require(['../components/MyInfo/PaymentSafe.vue'], resolve)
  },
  {
    path: '/PhoneSettings',
    name: 'PhoneSettings',
    component: resolve => require(['../components/MyInfo/PhoneSettings.vue'], resolve)
  },
  {
    path: '/EmailSettings',
    name: 'EmailSettings',
    component: resolve => require(['../components/MyInfo/EmailSettings.vue'], resolve)
  },
  {
    path: '/SetPassword',
    name: 'SetPassword',
    component: resolve => require(['../components/MyInfo/SetPassword.vue'], resolve)
  },
  {
    path: '/PaymentSettings',
    name: 'PaymentSettings',
    component: resolve => require(['../components/MyInfo/PaymentSettings.vue'], resolve)
  },
  {
    path: '/Biosetting',
    name: 'Biosetting',
    component: resolve => require(['../components/MyInfo/Biosetting.vue'], resolve)
  },
  {
    path: '/LogisticsPush',
    name: 'LogisticsPush',
    component: resolve => require(['../components/Chat/LogisticsPush.vue'], resolve)
  },

]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'hash',
  scrollBehavior(to, from, savedPosition) { //跳转页面是直接跳转到页面的顶部
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  },
  routes
})
export default router